//1.参数的可选类型
function foo(x:number,y?:number){
    console.log(x,y);
}

foo(1)  //1,undefined
foo(1,2)    //1,2
//就算是可选类型y的类型是number|undefined

//可选类型必须放在必传参数的后面

//2.默认参数
function foo2(x:number,y:number=6){
    console.log(x,y);
}

foo2(1)  //1,6
foo2(1,2)//1,2
//这时候y的类型其实是undefined和number类型的联合

//3.剩余参数
function sum(...nums:number[]){
    let total = 0
    for(const num of nums){
        total += num
    }
    return total
}
const result1 = sum(10,20,30)
console.log(result1);   //60
const result2 = sum(10,20,30,40)
console.log(result2);   //100


export{}
